{% if page.layout == 'post' %}
<div class="progress-indicator"></div>
<script>
jQuery(document).ready(function($) {
  var $w = $(window);
  var $prog2 = $('.progress-indicator');
  var wh = $w.height();
  var h = $('body').height();
  var sHeight = h - wh;
  if (!window.requestAnimationFrame) {
    window.requestAnimationFrame = function(callback){
      return setTimeout(callback, 17);
    };
  };
  $w.on('scroll', function() {
    window.requestAnimationFrame(function(){
      var perc = Math.max(0, Math.min(1, $w.scrollTop() / sHeight));
      updateProgress(perc);
    });
  });

  function updateProgress(perc) {
    $prog2.css({width: perc * 100 + '%'});
  }
  setTimeout(() => {
    window.toTop && window.toTop()
  }, 0)
});
</script>
{% endif %}